package project.gui.creators;



import framework.events.Event;
import framework.gui.GUI;
import framework.gui.GUIObject;
import framework.gui.GUIObjectCreator;
import project.events.antEvents.AntDiedEvent;
import project.events.antEvents.SearchingExplorationAntCreatedEvent;
import project.events.antEvents.SearchingExplorationAntDiedEvent;
import project.gui.objects.GUISearchingExplorationAnt;

public class GUISearchingExplorationAntCreator extends GUIObjectCreator {

	public GUISearchingExplorationAntCreator(GUI gui) {
		super(gui);
	}

	@Override
	protected GUIObject createGUIObject(Event event) {
		if (event instanceof SearchingExplorationAntCreatedEvent) {
			SearchingExplorationAntCreatedEvent e = (SearchingExplorationAntCreatedEvent) event;
			System.out.println("[GUISearchingExplorationAntCreator] searching exploration ant created with id: " + e.getId());
			System.out.println(e.getPosition());
			return new GUISearchingExplorationAnt(e.getId(), e.getPosition());
		} else {
			throw new IllegalStateException();
		}
	}

	@Override
	protected Class<? extends Event> getCreationEventClass() {
		return SearchingExplorationAntCreatedEvent.class;
	}

	@Override
	protected Class<? extends Event> getDestroyEventClass() {
		return SearchingExplorationAntDiedEvent.class;
	}

	@Override
	protected GUIObject getDestroyGUIObject(Event event) {
		if (event instanceof SearchingExplorationAntDiedEvent) {
			SearchingExplorationAntDiedEvent e = (SearchingExplorationAntDiedEvent) event;
			System.out.println("[GUISearchingExplorationAntCreator] searching exploration ant DIED with id: " + e.getId());
			return new GUISearchingExplorationAnt(e.getId(), null);
		} else {
			throw new IllegalStateException();
		}
	}
}
